package com.inpion.board.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.inpion.board.criteria.BoardCriteria;
import com.inpion.board.dao.BoardDao;
import com.inpion.board.entity.Board;
import com.inpion.board.entity.BoardItem;
import com.inpion.board.entity.Label;
import com.inpion.framework.database.sqlmap.DefaultSqlSession;

@Repository(value="com.inpion.board.dao.boardDao")
public class BoardDaoImpl extends DefaultSqlSession implements BoardDao {
	
	@Override
	public void insertBoard(Board board) {
		this.getSqlSession().insert("Board.insertBoard", board);
	}

	@Override
	public String selectNewBoardNo() {
		return this.getSqlSession().selectOne("Board.selectNewBoardNo");
	}

	@Override
	public Board selectBoard(String boardNo) {
		return this.getSqlSession().selectOne("Board.selectBoard", boardNo);
	}
	
	@Override
	public void insertLabel(Label label) {
		this.getSqlSession().insert("Board.insertLabel", label);
	}
	
	@Override
	public String selectNewLabelNo() {
		return this.getSqlSession().selectOne("Board.selectNewLabelNo");
	}

	@Override
	public List<Label> selectLabelListByBoardNo(String boardNo) {
		return this.getSqlSession().selectList("Board.selectLabelListByBoardNo", boardNo);
	}
	
	@Override
	public void insertBoardItem(BoardItem boardItem) {
		this.getSqlSession().insert("Board.insertBoardItem", boardItem);
	}

	@Override
	public String selectNewBoardItemNo() {
		return this.getSqlSession().selectOne("Board.selectNewBoardItemNo");
	}

	@Override
	public BoardItem selectBoardItem(String boardItemNo) {
		return this.getSqlSession().selectOne("Board.selectBoardItem", boardItemNo);
	}

	@Override
	public long selectBoardItemCount(BoardCriteria criteria) {
		return this.getSqlSession().selectOne("Board.selectBoardItemCount", criteria);
	}

	@Override
	public List<BoardItem> selectBoardItemList(BoardCriteria criteria) {
		return this.getSqlSession().selectList("Board.selectBoardItemList", criteria);
	}

	@Override
	public void updateBoardItem(BoardItem boardItem) {
		this.getSqlSession().update("Board.updateBoardItem", boardItem);
	}

	@Override
	public void deleteBoardItem(String boardItemNo) {
		this.getSqlSession().delete("Board.deleteBoardItem", boardItemNo);
	}

}
